using System;
using System.Globalization;

namespace InfoJetSoft.Service.Util
{
	public class DdddDateTime
	{
		private DateTime dateTime;
		private bool valid = false;

		public bool Valid {
			get {
				return valid;
			}
			
			set {
				this.valid = value;
			}
		}

		public DateTime DateTime {
			get {
				return dateTime;
			}
			
			set {
				this.dateTime = value;
			}
		}

		public static DdddDateTime ddddParse( string value_Renamed, string dateFormat, CultureInfo locale ){
			DdddDateTime fDate = new DdddDateTime();
			SimpleDateFormat sdf = null;
			if( dateFormat.StartsWith( "dddd " ) ){
				int spaceIndex = value_Renamed.IndexOf( " " );
				if( spaceIndex > 0 ){
					value_Renamed = value_Renamed.Substring( spaceIndex );
				}
				try {
					sdf = new SimpleDateFormat(dateFormat.Substring( 5 ), locale );
					DateTime dateTime = sdf.parse( value_Renamed );
					fDate.DateTime = dateTime;
					fDate.Valid = true;
					return fDate;
				}
				catch (System.FormatException e) {
				}
			}
			fDate.Valid = false;
			return fDate;
		}

	}
}
